package com.erclab.internal.xpresso.handlers;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import org.apache.commons.dbutils.ResultSetHandler;

import com.erclab.internal.xpresso.reports.ReportView;

public class ReportViewHandler implements ResultSetHandler {

	public Object handle(ResultSet rs) throws SQLException {
		ArrayList<ReportView> reportViews = new ArrayList<ReportView>();
		while (rs.next()){
			ReportView v = new ReportView();
			this.setViewProperties(v, rs);
			reportViews.add(v);
				
		}		
		return reportViews;
	}

	private void setViewProperties(ReportView v, ResultSet rs) throws NumberFormatException, SQLException {
		v.setIdReport(rs.getInt("IdReport"));
		v.setIdView(rs.getInt("IdView"));
		v.setViewPath(rs.getString("ViewPath"));
		v.setViewName(rs.getString("ViewName"));
		
	}

}
